package top.itlir.edc.service.impl;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import top.itlir.edc.dao.CourierRepository;
import top.itlir.edc.domain.Courier;
import top.itlir.edc.service.CourierService;

@Service
@Transactional
public class CourierServiceImpl implements CourierService {
	
	@Autowired
	private CourierRepository courierRepository;

	@Override
	public void save(Courier courier) {
		courierRepository.save(courier);
	}

	@Override
	public Page<Courier> pageQuery(Specification<Courier> spec, Pageable pageable) {
		return courierRepository.findAll(spec, pageable);
	}

	@Override
	public void delete(String ids) {
		String[] idsArr = ids.split(",");
		
		for (String id : idsArr) {
			courierRepository.updateDeltag(Integer.valueOf(id));
		}
	}

	@Override
	public void restore(String ids) {
		String[] idsArr = ids.split(",");
		
		for (String id : idsArr) {
			courierRepository.restoreDeltag(Integer.valueOf(id));
		}
	}

	@Override
	public List<Courier> findAll() {
		return courierRepository.findAll();
	}

	@Override
	public List<Courier> listajax() {
		return courierRepository.listajax();
	}
	

}
